package top.lingkang.authoritypro.data.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import top.lingkang.authoritypro.data.entity.Menu;

import java.util.List;
import java.util.Set;

@Repository
public interface MenuDao extends JpaRepository<Menu, Long> {
    @Query(value = "select m from Menu m order by m.parentCode,m.seq")
    List<Menu> getMenuList();

    @Modifying// 修改注解
    @Query("update Menu m set m.status=?2 where m.code=?1")
    void updateStatus(String code, Integer status);

    Menu findByCode(String code);

    List<Menu> findByParentCode(String code);

    @Modifying// 修改注解
    @Query("delete from Menu where code in ?1")
    int deleteAllByCodes(Set<String> codes);
}
